﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls.Primitives;

namespace CsharpWpfManual
{
    class PopupEx:Popup
    {

        private static System.Windows.Threading.DispatcherTimer readDataTimer = new System.Windows.Threading.DispatcherTimer();



        public PopupEx()
        {

            readDataTimer.Tick += new EventHandler(timeCycle);
            readDataTimer.Interval = new TimeSpan(0, 0, 0, 5);

        }
        /// <summary>
        /// 重写opend事件，打开后，启动定时器开始计时，先写死5秒把
        /// </summary>
        /// <param name="e"></param>
        protected override void OnOpened(EventArgs e)
        {
            base.OnOpened(e);
            readDataTimer.IsEnabled = true;
        
            readDataTimer.Start();
        }


        public  void timeCycle(object sender, EventArgs e)
        {
            if(IsOpen==true)
            {
                IsOpen = false;
            }
            readDataTimer.IsEnabled = false;

        }
    }

    
}
